import axios from 'axios'
import { param } from 'jquery'
import Cookie from 'js-cookie'
const instance = axios.create({
    baseURL:process.env.IP_ENV, // api的base_url
    timeout: 35000, // 请求超时时间
    headers: { 'content-type': 'application/json;charset=UTF-8' },
    withCredentials: true
})

const gisinstance = axios.create({
    // baseURL: 'http://10.10.10.26:8081/', // api的base_url
    baseURL: 'http://192.168.1.106:8081/', // api的base_url
    timeout: 35000, // 请求超时时间
    headers: { 'content-type': 'application/json;charset=UTF-8' }
})

const fcinstance = axios.create({
    baseURL: '/adminanalysis', // api的base_url
    timeout: 35000, // 请求超时时间
    headers: { 'content-type': 'application/json;charset=UTF-8' },
    withCredentials: true
})

// 拦截请求
instance.interceptors.request.use(
    //  可以在此处添加 token
    config => {
        // if (Cookie.get('qzds-token')) {
        //     config.headers['X-Access-Token'] = Cookie.get('qzds-token') // 让每个请求携带自定义token 请根据实际情况自行修改
        // }
        return config
    }, error => {
        return Promise.reject(error)
    })
// 拦截响应
instance.interceptors.response.use(res => {
    // 可以在此处拦截接口错误
    return res
}, error => {
    return Promise.reject(error)
})

//设置cookie
export function setCookie(token) {
    return Cookie.set('qzds-token', token)
}

export function setSession(session) {
    return sessionStorage.setItem('isLogin', session)
}

//登录
export function login(params) {
    return instance.post('/login?' + params)
}


// 获取天气数据
export function weat() {
    return instance.get('/v3/homePage/getBarInfo')
}

// 概况总览
export function getGeneralSituation() {
    return instance.get('/v3/governanceElements/getGeneralSituation')
}

// 事件总览
export function getTownEventBasic(params) {
    return instance.get('/v3/governanceElements/getTownEventBasic?' + params)
}

// 事件趋势
export function getTownEventTrend(params) {
    return instance.get('/v3/governanceElements/getTownEventTrend?' + params)
}

// 事件排名
export function getTownEventRank(params) {
    return instance.get('/v3/governanceElements/getTownEventRank?' + params)
}

// 事件分类
export function getTownEventType(params) {
    return instance.get('/v3/governanceElements/getTownEventType?' + params)
}

// 事件中心
export function getTownEventCenter(params) {
    return instance.get('/v3/governanceElements/getTownEventCenter?' + params)
}

// 平台活力指数
export function getVitalityTrend(params) {
    return instance.get('v3/governanceElements/getVitalityTrend?' + params)
}

// 预警概况
export function getOverviewOfEarlyWarning() {
    return instance.get('/v3/governanceElements/getOverviewOfEarlyWarning')
}

// 预警中心
export function getOverviewOfEarlyWarningCenter(params) {
    return instance.get('/v3/governanceElements/getOverviewOfEarlyWarningCenter?' + params)
}

//事件高频词接口
export function getEventGPC(params) {
    return instance.get('/v3/warningAndPrediction/getHighFrequencyWords?' + params)
}

//网格数据接口
export function gettdtList() {
    return instance.get('/v3/tdt/tdtList')
}

//根据网格code查询网格信息
export function gettdinfo(params) {
    return instance.get('/grid/infoList?' + params)
}


////****************************gis接口//////////////////////

// 根据网格编号查询住房信息
export function selectZhufxxByGridId(params) {
    return gisinstance.get('/jmzfxx/selectZhufxxByGridId?gridId=' + params)
}

// 根据网格编号查询商户信息
export function selectShxxByGridId(params) {
    return gisinstance.get('/jmzfxx/selectShxxByGridId?gridId=' + params)
}

//根据网格编号查询重点场所信息
export function selectZdcsByGridId(params) {
    return gisinstance.get('/jmzfxx/selectZdcsxxByGridId?gridId=' + params)
}

// 查询自住房列表信息
export function getzzflist() {
    return gisinstance.get('/jmzfxx/selectGridForZiZhuFang')
}

// 查询商户列表信息
export function getshlist() {
    return gisinstance.get('/jmzfxx/selectGridForShangHu')
}

// 查询重点场所列表信息
export function getzdcslist() {
    return gisinstance.get('/jmzfxx/selectGridForZDCS')
}

// 事件中心（点击->事件详情）
export function getEventListDetail(origin, eventId) {
    return instance.get(`/v3/governanceElements/getEventListDetail/${origin}/${eventId}`)
}

// 处理流程
export function processAndViditors(eventId) {
    return instance.get(`eventFlow/maodiao/processAndViditors/${eventId}`)
}

// 分组列表
export function zzdjbGroup(params) {
    return instance.get('/zzdjb/group?' + params)
}

// 预警交办
export function addDingdingAssign(params) {
    return instance.post('/zzdjb/insert?', params)
}


export async function getQyyu() {
    return instance.get('/eventFlow/pingAnFlow/getAreaCode')
}

// 部门管理中的区域选择
export function getV2Region(params) {
    return instance.get('/region/v2?' + params)
}

export async function getRegionDeptAuth(params) {
    return instance.get('/region/dept/auth?' + params)
}

// 获取钉钉列表
export function getDeptList(params) {
    return instance.get(`/dingtalk/getDept?phoneOrName=${params}`)
}

// 获取所有部门
export function getAllBuMen(params) {
    return instance.get('/dept/all?' + params)
}

export function createHandheld(params) {
    return instance.post('/v2/tblHouseRegister/createPalmRoom?' , params)
}
// 根据手机号获取钉钉id
export function getDingDingId(phone) {
    return instance.get('/v2/tblHouseRegister/getDingDingIdByPhone?phone=' + phone)
}

// 历史会议查询
export function getHistoryPalmRoom(params) {
    return instance.get('/v2/tblHouseRegister/getHistoryPalmRoom?' , params)
}

// 事件进度查询
export function getPalmRoomProcess(params) {
    return instance.get('/v2/tblHouseRegister/getPalmRoomProcess?' , params)
}

// 获取用户信息
export function getUserInfo(params) {
    return instance.get('/v3/governanceElements/getUserInfo' , params)
}

// 查询事件类型
export function getIncidentType() {
    return instance.get('/v2/tblHouseRegister/incident_stype')
}

// 预警核销
export function qjWarningEdit (params) {
    return instance.post('qjWarning/edit?' + params)
  }

// 事件交办-事件类型
export function getEventFlowGridsTqjbTypes () {
    return instance.get('/eventFlow/tqjbTypes')
  }

// 预警交办 交办到天阙
export function wrningAssignFlowSecond (params, operate) {
    return instance.post(`/eventFlow/flow/${operate}`,params)
  }

//在线分词,参数名：content,length
export function getgpcbycontent(params) {
    return fcinstance.get('/v2/hotWord/getWord?' + params)
}

export function geteventwithname(name,sjhm) {
    return gisinstance.get(`/xfxx/selectXfxxByNameOrPhone/?name=${name}&sjhm=${sjhm}`)
}

// 根据网格编号查询商户信息
export function selectGridForShangHu(params) {
    return gisinstance.get('/jmzfxx/selectShangHuGsjcXXByXydm?xydm=' + params)
}

// 删除视频会议
export function deleteConference (params) {
    return instance.delete(`/videoFusion/deleteConference`,params)
  }

  // 创建视频会议
export function createVideoConference (params) {
    return instance.get(`/videoFusion/createVideoConference`,params)
  }

// 一键解除禁言
export function unForbiddenSpeech (params) {
    return instance.delete(`/videoFusion/unForbiddenSpeech`,params)
  }


// 一键禁言
export function forbiddenSpeech (params) {
    return instance.delete(`/videoFusion/forbiddenSpeech`,params)
  }